{% extends "index.html" %}
{% block linkcss %}
    {{ super() }}
    <script type="text/javascript" src="{{ url_for('static', filename='css/jquery.dataTables.min.css') }}"></script>
{% endblock %}
{% block title %}
    报告管理
{% endblock %}
{% block page_nav %}
    <li>报告</li>
    <li>报告管理</li>
{% endblock %}
{#页面内容#}
{% block content %}
    <!--查询条件-->
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-body">
                    <form class="form-horizontal" method="POST"
                          action="{{ url_for('view.report_manage') }}" id="form_query" name="form_query">
                        <div class="form-group">
                            <label class="control-label col-md-1 col-md-offset-1" for="maintenanceContractNumber">合同编号</label>
                            <div class="col-md-2">
                                <input id="maintenanceContractNumber" class="form-control" type="text" name="maintenanceContractNumber" placeholder="合同编号">
                            </div>
                            <label class="control-label col-md-1" for="idCode">识别码</label>
                            <div class="col-md-2">
                                <input id="idCode" class="form-control" type="text" name="idCode" placeholder="识别码">
                            </div>
                            <label class="control-label col-md-1" for="userEntityName">使用单位</label>
                            <div class="col-md-3">
                                <input id="userEntityName" class="form-control" type="text" name="userEntityName"
                                       placeholder="使用单位">
                            </div>
                        </div>
                        <div class="card-footer">
                            <div class="row">
                                <div class="col-md-2 col-md-offset-4">
                                    <button class="btn btn-primary icon-btn" type="button" id="bt_query">
                                        <i class="fa fa-fw fa-lg fa-check-circle"></i>查询
                                    </button>
                                </div>
                                <div class="col-md-2 col-md-offset-1">
                                    <button class="btn btn-primary icon-btn" type="button"><i class="fa fa-fw fa-lg fa-refresh"></i>重置</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--查询结果显示表格-->
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-hover table-bordered" id="sampleTable">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>识别码</th>
                                <th>使用单位</th>
                                <th>设备名称</th>
                                <th>出厂编号</th>
                                <th>报告编号</th>
                                <th>报告时间</th>
                                <th>联系人</th>
                                <th>联系电话</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                {% for id, report in reports %}
                                    <tr>
                                        <td>{{ id+1 }}</td>
                                        <td>{{ report.idCode }}</td>
                                        <td>{{ report.userEntityName }}</td>
                                        <td>{{ report.deviceName }}</td>
                                        <td>{{ report.factoryNumber }}</td>
                                        <td>{{ report.reportID }}</td>
                                        <td>{{ report.reportYear }}</td>
                                        <td>{{ report.contactPerson }}</td>
                                        <td>{{ report.contactNumber }}</td>
                                        <td>
                                            <a href="{{ url_for('view.report_show', report_idCode=report.idCode) }}" target="_blank">查看</a>
                                            &nbsp&nbsp&nbsp&nbsp
                                            <a href="{{ url_for('view.report_download', report_id=report.reportID) }}">下载</a>
                                            &nbsp&nbsp&nbsp&nbsp
                                            <a href="" data-toggle="modal" data-target="#myModal{{ id+1 }}">删除</a>
                                            <!-- 弹出页面 -->
                                            <div class="modal fade" id="myModal{{ id+1 }}" tabindex="-1" role="dialog"
                                                 aria-labelledby="myModalLabel">
                                                <div class="modal-dialog modal-sm" role="document">
                                                    <div class="modal-content">
                                                        <div class="modal-header alert alert-danger">
                                                            <button type="button" class="close" data-dismiss="modal"
                                                                    aria-label="Close"><span aria-hidden="true">&times;</span>
                                                            </button>
                                                            <h4 class="modal-title" id="myModalLabel">提示</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <div class="row">
                                                                <div class="col-md-12">
                                                                    <span>删除编号为{{ report.reportID }}的电梯报告？</span>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <div class="col-md-3 col-md-offset-2">
                                                                <a class="btn btn-danger" href="{{ url_for('view.report_del', report_id=report.reportID) }}">确定</a>
                                                            </div>
                                                            <div class="col-md-2 col-md-offset-2">
                                                                <a class="btn btn-default" data-dismiss="modal">取消</a>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
<!-- Javascripts-->
{% block script %}
	{{ super() }}
    {#  表格插件 dataTables  #}
    <script type="text/javascript" src="{{ url_for('static', filename='js/dataTables/jquery.dataTables.min.js') }}"></script>
    <script type="text/javascript" src="{{ url_for('static', filename='js/dataTables/dataTables.bootstrap.min.js') }}"></script>
    {# 提示插件 #}
    <script type="text/javascript" src="{{ url_for('static', filename='js/alert.js') }}"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            // 表格插件初始化
            $('#sampleTable').DataTable({
                "language": {
                    "url": "{{ url_for('static', filename='js/dataTables/Chinese.json') }}"
                },
            });
        });
        $("#bt_query").click(function () {
            if (($('#maintenanceContractNumber').val() == "") && ($('#idCode').val() == "") && ($('#userEntityName').val() == "")) {
                ShowFailure('请输入查询条件');
            }
            else {
                $('#form_query').submit();
            }
        });
    </script>
{% endblock %}